package com.nsn.das.midas.model.component;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.nsn.das.midas.model.BaseEntity;
import com.nsn.das.midas.model.user.DASUser;
import com.nsn.das.utils.DateUtils;

@Entity
@Table(name = "revision_history")
public class RevisionHistory extends BaseEntity{
	private static final long serialVersionUID = 3410560060538144372L;
	
	private String comment;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="author_id")
	private DASUser author;
	private Date createdAt;
	
	@Override
	public String toString(){
		return new StringBuffer(DateUtils.date2String(getCreatedAt()) 
				+ " " + getAuthor().getUsername() 
				+ " " + getComment()).toString();
	}
	
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public DASUser getAuthor() {
		return author;
	}
	public void setAuthor(DASUser author) {
		this.author = author;
	}
	public Date getCreatedAt() {
		return createdAt;
	}
	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}
}
